#include "ObjectGroup.hpp"

namespace maploader
{
	ObjectGroup::ObjectGroup() : myName(""), myColor(0) {}

	ObjectGroup ObjectGroup::Load(const pugi::xml_node& node)
	{
		ObjectGroup objectgroup;

		std::stringstream convert;
		if (std::string(node.attribute("color").value()) != "")
		{
			convert << std::string(node.attribute("color").value()).substr(1).insert(0, "0x");
		} else {
			convert << "0x0";
		}
		convert >> std::hex >> objectgroup.myColor;

		objectgroup.myName = std::string(node.attribute("name").value());
		
		for (pugi::xml_node object = node; object; object = object.next_sibling("object"))
			objectgroup.myObjects.push_back(Object::Load(object));

		return objectgroup;
	}
}